home *** CD-ROM | disk | FTP | other *** search
- # makemap.awk : 386link の .MAP 出力より、メモリー使用一覧
- # を作成する。
-
- BEGIN {
- do { getline; } while ($0 != "Segment map");
- getline; getline; getline
- }
-
- {
- if ($0 == "")
- exit;
- name = substr($0,1,14); gsub(/[ \t]/,"",name);
- type = substr($0,29,13); gsub(/[ \t]/,"",type);
- size = hextoi(substr($0,59,8));
-
- if (substr(name,1,1) == "_")
- name = "?other" type
- if (type == "")
- type = (name=="CSEG"?"CODE":name=="DSEG"?"DATA":"NONAME");
-
- sizelist[name] += size
- typelist[name] = type
- sizetotal[type] += size
- }
-
- function hextoi(hexstr)
- {
- n = 0;
- toupper(hexstr);
- gsub(/[ \t]/,"",hexstr);
- for (i=1; i<=length(hexstr); i++)
- n = n * 16 + index("0123456789ABCDEF",substr(hexstr,i,1)) - 1;
- return n;
- }
-
- END {
- for (i in sizelist)
- {
- rate = (sizelist[i]/sizetotal[typelist[i]]) * 100;
- printf("%-14s %8d %7.2f(%%) (%-6s) ",i,sizelist[i],rate,typelist[i]);
- rr = int(rate*3);
- if (rr > 25)
- printf("*");
- else {
- for (j=0; j<rr; j++)
- printf(":");
- }
- printf("\n");
- }
- }
-